<?php
/**
 *   Kaltura Browser - administrator/components/com_kaltura/views/contenteditor/tmpl/default.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2011 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');
?>
<form action="index.php" method="post" name="adminForm">
<div id="filterarea">
    <?php echo JText::_('KALTURA_SEARCH'); ?>
    <input type="text" name="freesearch" id="freesearch" value="" />
    <input type="submit" name="submit" />
</div>
<div id="editcell" style="overflow:auto; height:100%;">
    <table class="adminlist">
        <thead><tr>
            <th width="5"><?php echo JText::_('ID'); ?></th>
            <th width="100"><?php echo JText::_('KALTURA_NAME'); ?></th>
            <th width="100"><?php echo JText::_('KALTURA_DESC'); ?></th>
            <th width="20"><?php echo JText::_('KALTURA_IS_VISIBLE'); ?></th>
            <?php foreach($this->fields as $field) { ?>
                <th width="100"><?php echo $field->field_label; ?></th>
            <?php } ?>
        </tr></thead>
        <tfoot>
		    <tr>
			    <td colspan="100"><?php echo $this->pagination->getListFooter(); ?></td>
		    </tr>
	    </tfoot>
        <tbody>
            <?php
            $k = 0;
            foreach ($this->entries->objects as $i => $entry) { ?>
                <tr class="row<?php echo $k; ?>">
                    <td><?php echo $entry->id; ?></td>
                    <td>
                        <div class="editbutton editlinktup hasTip" title="<?php echo JText::_('EDIT'); ?>: name::<?php echo $entry->name; ?>" id="editbutton_<?php echo $entry->id.'_name'; ?>"></div>
                        <div class="edittable" id="edit_<?php echo $entry->id.'_name'; ?>">
                            <div class="label" id="label_<?php echo $entry->id.'_name'; ?>"><?php echo $entry->name; ?></div>
                            <div class="field" id="field_<?php echo $entry->id.'_name'; ?>">
                                <div class="close_button" id="editbutton_<?php echo $entry->id.'_name'; ?>"></div>
                                <textarea class="area_field" id="input_<?php echo $entry->id.'_name'; ?>"><?php echo $entry->name; ?></textarea>
                                <div class="clear"></div>
                                <button onclick="return false;" id="send_<?php echo $entry->id.'_name'; ?>" class="send"><?php echo JText::_('KALTURA_SEND'); ?></button>
                                <div class="clear"></div>
                            </div>
                        </div>
                    </td>
                    <td>
                        <div class="editbutton editlinktup hasTip" title="<?php echo JText::_('EDIT'); ?>: description::<?php echo $entry->name; ?>" id="editbutton_<?php echo $entry->id.'_description'; ?>"></div>
                        <div class="edittable" id="edit_<?php echo $entry->id.'_description'; ?>">
                            <div class="label" id="label_<?php echo $entry->id.'_description'; ?>"><?php echo $entry->description; ?></div>
                            <div class="field" id="field_<?php echo $entry->id.'_description'; ?>">
                                <div class="close_button" id="editbutton_<?php echo $entry->id.'_description'; ?>"></div>
                                <textarea class="area_field" id="input_<?php echo $entry->id.'_description'; ?>"><?php echo $entry->description; ?></textarea>
                                <div class="clear"></div>
                                <button onclick="return false;" id="send_<?php echo $entry->id.'_description'; ?>" class="send"><?php echo JText::_('KALTURA_SEND'); ?></button>
                                <div class="clear"></div>
                            </div>
                        </div>
                    </td>
                    <td>
                        <div class="togglevisible" title="toggle_<?php echo JText::_('TOGGLE_VISIBLE'); ?>" 
                             id="visible_<?php echo $entry->id; ?>">
                            <?php if (isset($entry->visible)) { ?>
                                <?php if ($entry->visible) { ?>
                                    <img src="components/com_kaltura/assets/yes.png" alt="yes" />
                                <?php } else { ?>
                                    <img src="components/com_kaltura/assets/no.png" alt="no" />
                                <?php } 
                            } else { ?>
                                <img src="components/com_kaltura/assets/warn.png" alt="undefined" />
                            <?php } ?>
                        </div>
                    </td>
                    <?php foreach ($this->fields as $field) {
                        $value = $this->kmodel->getValue($entry->id, $field->id); ?>
                        <td>
                        	<div class="editbutton editlinktip hasTip" title="<?php echo JText::_('EDIT'); ?>: <?php echo $field->field_label; ?>::<?php echo $entry->name; ?>" id="editbutton_<?php echo $entry->id.'_'.$field->id; ?>"></div>
                            
                            <div class="editable" id="edit_<?php echo $entry->id.'_'.$field->id; ?>">
                            <div class="label" id="label_<?php echo $entry->id.'_'.$field->id;?>"><?php echo $value; ?></div>
                            <div class="field" id="field_<?php echo $entry->id.'_'.$field->id;?>">
                               <!-- <input type="text" id="input_<?php echo $entry->id.'_'.$field->id;?>" value="<?php echo $value; ?>" /> --> 
                                <div class="close_button" id="editbutton_<?php echo $entry->id.'_'.$field->id; ?>"></div>
                                <?php if ($field->field_type == 1) { 
                                    $values = $this->kmodel->getFieldValues($field->id); ?>
                                    <select id="input_<?php echo $entry->id.'_'.$field->id;?>">
                                        <?php foreach ($values as $val) { ?>
                                            <option value="<?php echo $val->field_value; ?>">
                                                <?php echo $val->field_value; ?>
                                            </option>
                                        <?php } ?>
                                    </select>
                                <?php } else { ?>
                                <textarea class="area_field" id="input_<?php echo $entry->id.'_'.$field->id;?>">
                                    <?php echo $value; ?>
                                </textarea>
                                <?php } ?>
                               
                                <div class="clear"></div>

                                <button onclick="return false;" id="send_<?php echo $entry->id.'_'.$field->id; ?>" class="send"><?php echo JText::_('KALTURA_SEND'); ?></button>
         						
         						<div class="clear"></div>
         						
                            </div>
                        </div>
                       
                        </td>
                    <?php } ?>
                </tr>
            <?php $k = 1 - $k; } ?>
        </tbody>
    </table>
</div>

    <input type="hidden" name="option" value="com_kaltura" />
    <input type="hidden" name="task" value="showcontent" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="controller" value="contentselector" />
    <input type="hidden" id="iid" name="iid" value="<?php echo JRequest::getVar('iid'); ?>" />
</form>
